﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace BookClubIt.UserControls
{
    public partial class currentbook : BaseUserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            DTO.BookClub club = BookClubProcessorInstance.GetBookClubById(CID);
             string CurrentUri = Page.Request.Url.AbsoluteUri;
            DTO.Book current = BookProcessorInstance.GetCurrentBook(CID);

            //if current page is bookshelf page add jquery ui droppable functions
            if (CurrentUri.Contains("bookshelf.aspx") && HttpContext.Current.User.Identity.IsAuthenticated && BookClubProcessorInstance.IsLeader(CurrentUserId, CID))
            {
                divShelfContainer.Attributes.Add("class", "shelfcontainer droppable");
                divShelfContainer.Visible = true;
                pnlNoBooks.Visible = false;

                if (current.Id == 0)
                {
                    imgCurrentBook.ImageUrl = "../images/nobook.png";
                    lnkDiscussBook.Visible = false;
                    lnkBookDetails.Visible = false;
                  
                }
                else
                {
                    lnkBookDetails.NavigateUrl = "../book.aspx?id=" + current.Id;
                    imgCurrentBook.ImageUrl = current.MediumImageURL;

                }

            }
            else if (current.Id == 0)
            {
                divShelfContainer.Visible = false;
                pnlNoBooks.Visible = true;
              
            }
            else
            {
                lnkBookDetails.NavigateUrl = "../book.aspx?id=" + current.Id;
                imgCurrentBook.ImageUrl = current.MediumImageURL;
            }
                lnkBookShelf.NavigateUrl = "~/bookclub/bookshelf.aspx?id=" + CID;
                lnkDiscussBook.NavigateUrl = "~/bookclub/discussions.aspx?id=" + CID;
               

        }
    }
}